#pragma once
#include"nocopy.hpp"
#include<sys/types.h>
#include<sys/socket.h>
#include<cerrno>
#include<cstring>
#include<netinet/in.h>
#include<arpa/inet.h>

class inetaddr
{
public:
    inetaddr(const sockaddr_in& local)
    {
        _ip = inet_ntoa(local.sin_addr);
        _port = ntohs(local.sin_port);
    }

    string iP()
    {
        return _ip;
    }
    uint16_t port()
    {
        return _port;
    }

    string PrintDebug()
    {
        string ret = _ip;
        ret += ":";
        ret += to_string(_port);
        return ret;
    }

    ~inetaddr()
    {}
private:
    string _ip;
    uint16_t _port;
};